(function () {

	var $modal = $('#pop-modal');
	var iShopId = parseInt(page.url.get('id'));

	getPageData ({
		id:iShopId
	});

	function getPageData (Filter)
	 {
	 	var Filter = Filter;
	 	getJson(Domain+'/ec/usedSeek/doFindSeek.do', Filter, function (res) {

		  if(!res.success){
	
		    $('.am-modal-bd').text(res.errorMessage);
				$modal.modal();
				setTimeout(function () {
					$modal.modal('close');
				},iWiating);
				return;
		  }
		  else{

	  	 	renderTmp('#shopdetail', 'shopdetailtpl',res);
	  	 	 
		  }

		},function (error) {

			$('.am-modal-bd').text(language.ajaxFailed);
							$modal.modal();
						setTimeout(function () {
							$modal.modal('close');
						},iWiating);

		})
	 }

	 //获取求购热门列表
	 getHotQglist ({});
	 function getHotQglist (Filter)
	 {

	 	var Filter = Filter;
	 		
	 		if(!Filter.page&&!Filter.pageSize)
	 		{
	 			Filter.page = page.page;
	 			Filter.pageSize = page.pageSize;
	 		}
	 		
	 	getJson(Domain+'/ec/usedSeek/doFindHotSeekList.do', Filter, function (res) {

		  if(!res.success){
	
		    $('.am-modal-bd').text(res.errorMessage);
				$modal.modal();
				setTimeout(function () {
					$modal.modal('close');
				},iWiating);
				return;
		  }
		  else{

	  	 	  page.nowPage = res.data.pageId;
      		  page.pageCount = res.data.pageCount;
      		  
      		  if(page.pageCount<=1)
      		  {
      		  	$('.page').remove(); //不满2页 删掉分页元素
      		  }

      		  if(!res.data.rows.length){
		        $('.page').remove();
		        $('#itemlist').append('<li class="empty_div">没有相关的商品哦~</li>');
		        return
		      }

		     $('#itemlist').empty();

			 renderTmp('#itemlist', 'itemlisttpl',res);

		  }

		},function (error) {

			$('.am-modal-bd').text(language.ajaxFailed);
							$modal.modal();
						setTimeout(function () {
							$modal.modal('close');
						},iWiating);
		})

	 }

	 //右侧分页(下翻)
	 $('.am-icon-angle-down').on('click',function () {

	 	$('.am-icon-angle-up').removeClass('no-page');

	 	if(page.nowPage>=page.pageCount)
	 	{
	 		$(this).addClass('no-page');
			return;
	 	}
	 	
		getHotQglist ({
			page:page.nowPage+1
			});
	 });

	 //右侧分页(上翻)
	 $('.am-icon-angle-up').on('click',function () {

	 	$('.am-icon-angle-down').removeClass('no-page');

	 	if(page.nowPage<=page.pageCount)
	 	{
	 		$(this).addClass('no-page');
			return;
	 	}
	 	
		getHotQglist ({
			page:page.nowPage-1
			});
	 });

})();